#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<vector<int>> ret;
    void bfs(vector<int>& nums, vector<bool>& visit, vector<int>& v)
    {
        for (int i = 0;i < nums.size();++i)
        {
            if (visit[i] == true)
            {
                continue;
            }
            v.push_back(nums[i]);
            visit[i] = true;
            bfs(nums, visit, v);
            visit[i] = false;
            v.pop_back();
        }
        if (v.size() == nums.size())
        {
            ret.push_back(v);
        }
        return;
    }
    vector<vector<int>> permute(vector<int>& nums)
    {
        vector<bool> visit(nums.size(), false);
        vector<int> v;
        bfs(nums, visit, v);
        return ret;
    }
};